<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2324：[ZJOI2011]营救皮卡丘</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[ZJOI2011]营救皮卡丘</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[ZJOI2011]营救皮卡丘</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [ZJOI2011]营救皮卡丘                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：256MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">皮卡丘被火箭队用邪恶的计谋抢走了！这三个坏家伙还给小智留下了赤果果的挑衅！为了皮卡丘，也为了正义，小智和他的朋友们义不容辞的踏上了营救皮卡丘的道路。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">火箭队一共有</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个据点，据点之间存在</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">M</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">条双向道路。据点分别从<font face="Times New Roman">1</font><font face="宋体">到</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">标号。小智一行</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">人从真新镇出发，营救被困在</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点的皮卡丘。为了方便起见，我们将真新镇视为<font face="Times New Roman">0</font><font face="宋体">号据点，一开始</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个人都在<font face="Times New Roman">0</font><font face="宋体">号点。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">由于火箭队的重重布防，要想摧毁</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点，必须按照顺序先摧毁<font face="Times New Roman">1</font><font face="宋体">到</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">-1<font face="宋体">号据点，并且，如果</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">-1<font face="宋体">号据点没有被摧毁，由于防御的连锁性，小智一行任何一个人进入据点</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，都会被发现，并产生严重后果。因此，在</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">-1<font face="宋体">号据点被摧毁之前，任何人是不能够经过</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点的。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">为了简化问题，我们忽略战斗环节，小智一行任何一个人经过</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点即认为</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点被摧毁。被摧毁的据点依然是可以被经过的。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个人是可以分头行动的，只要有任何一个人在</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">-1<font face="宋体">号据点被摧毁之后，经过</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点就被摧毁了。显然的，只要</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点被摧毁，皮卡丘就得救了。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">野外的道路是不安全的，因此小智一行希望在摧毁</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点救出皮卡丘的同时，使得</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个人所经过的道路的长度总和最少。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">请你帮助小智设计一个最佳的营救方案吧！</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<!--EndFragment--></p><hr/><h3>输入格式</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">第一行</span><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">包含</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">三个正整数</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">M</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">。表示一共有</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">+1<font face="宋体">个据点，分别从</font><font face="Times New Roman">0</font><font face="宋体">到</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">编号，以及</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">M</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">条无向边。一开始小智一行共</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">K</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个人均位于<font face="Times New Roman">0</font><font face="宋体">号点。&nbsp;</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">接下来</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">M</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">行，每行三个非负整数，第</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">行的整数为</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">A</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">B</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">，</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">L</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">。表示存在一条从</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">A</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点到</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">B</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">号据点的长度为</span><span style="font-size: 10.5pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">L</span><span style="font-size: 10.5pt; vertical-align: sub; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">i</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">的道路。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></p><hr/><h3>输出格式</h3><p><p class="p20" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'"><font face="宋体">仅包含一个整数</font></span><span style="font-size: 10.5pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">S</span><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">，为营救皮卡丘所需要经过的最小的道路总和。</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></p><hr/><h3>样例输入</h3><pre>3 4 2
0 1 1
1 2 1
2 3 100
0 3 1</pre><hr/><h3>样例输出</h3><pre>3
【样例说明】
小智和小霞一起前去营救皮卡丘。在最优方案中，小智先从真新镇前往1号点，接着前往2号据点。当小智成功摧毁2号据点之后，小霞从真新镇出发直接前往3号据点，救出皮卡丘。</pre><hr/><h3>提示</h3><p><p>对于100%的数据满足N &le; 150, M &le; 20 000, 1 &le; K &le; 10, Li &le; 10 000, 保证小智一行一定能够救出皮卡丘。至于为什么K &le; 10，你可以认为最终在小智的号召下，小智，小霞，小刚，小建，小遥，小胜，小光，艾莉丝，天桐，还有去日本旅游的黑猫警长，一同前去大战火箭队。</p></p><hr/><h3>题目来源</h3><p>Day2</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2324" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2324" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>